<template>
	<view class="wrap">
		<view class="tips">
			<view>姓名一旦保存，无法再次更改，请仔细核对！</view>
			

		</view>
		
		<view class="ipt-wrap">
			<view class="label">
				开户人
			</view>
			<view class="right">
				 <input :disabled="hasdata" v-model="bank_user"  type="text" placeholder="请输入开户人姓名" />
			</view>
			
		</view>
		
		<view class="ipt-wrap">
			<view class="label">
				开户银行
			</view>
			<view class="right">
				 <input v-model="bank_of_deposit"  type="text" placeholder="请输入开户银行" />
			</view>
			
		</view>
		<view class="ipt-wrap">
			<view class="label">
				银行卡号
			</view>
			<view class="right">
				 <input v-model="bank_card"  type="text" placeholder="请输入银行卡号" />
			</view>
			
		</view>
		
		<view class="next" @click="topay">
			保存
		</view>
		<paypass ref="yspay" @cancel="cancelpay" @submit="submitpay"></paypass>
		
	</view>
</template>


<script>
	
	import paypass from "@/components/ys-paypass/ys-paypass.vue";
	export default {
		components:{paypass},
		
		data() {
			return {
				
				hasid:false,
				hasdata:false,
				bank_card:'',
				bank_of_deposit:'',
				bank_user:''
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			topay(){
				
				if(this.bank_user==''){
					uni.showToast({
					    title: '请输入开户人姓名',
					    duration:4000,
						icon:'none'
					});
					return
				}
				if(this.bank_of_deposit==''){
					uni.showToast({
					    title: '请输入开户银行',
					    duration:4000,
						icon:'none'
					});
					return
				}
				if(this.bank_card==''){
					uni.showToast({
					    title: '请输入银行卡号',
					    duration:4000,
						icon:'none'
					});
					return
				}
				
				this.$refs.yspay.show();
			},
			
			submitpay(ex){
				this.subData(ex.value)
			},
			getData(){
				let that=this
				that.apiget('/api/user/get_bank_info').then(res => {
					if(res.Code==10200){
						let data=res.Data
						
						if(data.bank_user){
							that.hasdata=true
						}else{
							that.hasdata=false
						}
						
						

						that.bank_card=data.bank_card
						that.bank_of_deposit=data.bank_of_deposit
						that.bank_user=data.bank_user
					}
					
				}).catch(err=>{
					console.log(err)
				});
			},
			subData(pwd){
				let that=this
				
				
				
				
				
				
				
				
				
				that.apipost('/api/user/change_bank_info',{
					
					bank_card:that.bank_card,
					bank_of_deposit:that.bank_of_deposit,
					bank_user:that.bank_user,
					pwd:pwd
				},true).then(res => {
					if(res.Code==10200){
						that.hasdata=true
						uni.showToast({
						    title: res.Message,
						    duration:4000,
							icon:'none'
						});
						
					}
					
				}).catch(err=>{
					console.log(err)
				});
			}
		}
	}
</script>

<style>

	.next{
		
		background:#f9436b;
		color:#fff;
		width:640rpx;
		margin:0 auto;
		display:flex;
		justify-content: center;
		align-items: center;
		height:80rpx;
		margin-top:60rpx;
		border-radius:12rpx;
	}
	.ipt-wrap .label{
		width:160rpx;
		padding-left:30rpx;
	}
	.ipt-wrap .right{
		flex:1;
		display:flex;
		align-items: center;
		height:100%;
	}
	/* .right input{
		height:100%;
		display:flex;
		align-items: center;;
	} */
	.ipt-wrap{
		display:flex;
		align-items: center;
		width:640rpx;
		margin:0 auto;
		margin-top:30rpx;
		height:84rpx;
		line-height: normal;
		border:1rpx solid #b2b2b2;
		border-radius:18rpx;
		
	}

	/* .name-wrap{
		border-bottom:1rpx solid #e8e8e8
	} */
	.wrap{
		background:#f7f7f7;
		min-height:100%;
	}
	.tips{
		color:#333;
		line-height:70rpx;
		background:#eaeaea;
		padding:34rpx 44rpx 34rpx 30rpx;
	}
</style>
